#pragma once

#include "UserInterface.h"
#include<windows.h>
#pragma comment(lib, "user32")

#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0 )
#define ENTER_KEY 13

namespace Tasker {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::RichTextBox^  displayBox;
	protected: 
	private: System::Windows::Forms::TextBox^  commandBox;
	private: System::Windows::Forms::GroupBox^  grpBoxList;
	private: System::Windows::Forms::CheckedListBox^  checkedTaskList;
	private: System::Windows::Forms::DateTimePicker^  dateTimePicker1;
	private: System::Windows::Forms::Timer^  timerOut;
	private: System::ComponentModel::IContainer^  components;

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			this->displayBox = (gcnew System::Windows::Forms::RichTextBox());
			this->commandBox = (gcnew System::Windows::Forms::TextBox());
			this->grpBoxList = (gcnew System::Windows::Forms::GroupBox());
			this->checkedTaskList = (gcnew System::Windows::Forms::CheckedListBox());
			this->dateTimePicker1 = (gcnew System::Windows::Forms::DateTimePicker());
			this->timerOut = (gcnew System::Windows::Forms::Timer(this->components));
			this->grpBoxList->SuspendLayout();
			this->SuspendLayout();
			// 
			// displayBox
			// 
			this->displayBox->Cursor = System::Windows::Forms::Cursors::IBeam;
			this->displayBox->ImeMode = System::Windows::Forms::ImeMode::Off;
			this->displayBox->Location = System::Drawing::Point(12, 12);
			this->displayBox->Name = L"displayBox";
			this->displayBox->ReadOnly = true;
			this->displayBox->ScrollBars = System::Windows::Forms::RichTextBoxScrollBars::Vertical;
			this->displayBox->Size = System::Drawing::Size(307, 260);
			this->displayBox->TabIndex = 7;
			this->displayBox->TabStop = false;
			this->displayBox->Text = L"";
			// 
			// commandBox
			// 
			this->commandBox->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->commandBox->Location = System::Drawing::Point(12, 278);
			this->commandBox->Multiline = true;
			this->commandBox->Name = L"commandBox";
			this->commandBox->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
			this->commandBox->Size = System::Drawing::Size(307, 36);
			this->commandBox->TabIndex = 1;
			this->commandBox->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Form1::commandBox_KeyPress);
			// 
			// grpBoxList
			// 
			this->grpBoxList->Controls->Add(this->checkedTaskList);
			this->grpBoxList->Controls->Add(this->dateTimePicker1);
			this->grpBoxList->Location = System::Drawing::Point(325, 12);
			this->grpBoxList->Name = L"grpBoxList";
			this->grpBoxList->Size = System::Drawing::Size(194, 160);
			this->grpBoxList->TabIndex = 8;
			this->grpBoxList->TabStop = false;
			this->grpBoxList->Text = L"Tasks for";
			this->grpBoxList->Visible = false;
			// 
			// checkedTaskList
			// 
			this->checkedTaskList->FormattingEnabled = true;
			this->checkedTaskList->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"happy", L"birthday", L"to", L"you"});
			this->checkedTaskList->Location = System::Drawing::Point(6, 47);
			this->checkedTaskList->Name = L"checkedTaskList";
			this->checkedTaskList->Size = System::Drawing::Size(181, 109);
			this->checkedTaskList->TabIndex = 2;
			// 
			// dateTimePicker1
			// 
			this->dateTimePicker1->Location = System::Drawing::Point(6, 19);
			this->dateTimePicker1->Name = L"dateTimePicker1";
			this->dateTimePicker1->Size = System::Drawing::Size(181, 20);
			this->dateTimePicker1->TabIndex = 1;
			// 
			// timerOut
			// 
			this->timerOut->Interval = 1000;
			this->timerOut->Tick += gcnew System::EventHandler(this, &Form1::timerOut_Tick);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(332, 343);
			this->Controls->Add(this->grpBoxList);
			this->Controls->Add(this->commandBox);
			this->Controls->Add(this->displayBox);
			this->Name = L"Form1";
			this->Text = L"Tasker";
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
			this->grpBoxList->ResumeLayout(false);
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
				 // Testing generateMessage
				 //String^ str2 = gcnew String(UserInterface::MESSAGE[UserInterface::MESSAGE_TYPE::ADDED].c_str());
				 //displayBox->AppendText(str2);

				 //Demonstrate usage of generateMessage
				 /*UserInterface UI;
				 String^ str2 = gcnew String(UI.generateMessage(UserInterface::MESSAGE_TYPE::ADDED, "asdfjk").c_str());
				 displayBox->AppendText(str2);*/
				 UserInterface UI;
				 printMessage(UI.generateWelcomeMessage());
				 UI.startingExecutor();
			 }

			 void printMessage(string msg) {
				displayBox->Clear();
				String^ display = gcnew String(msg.c_str());
				displayBox->AppendText(display);
			}

	private: System::Void commandBox_KeyPress(System::Object^  sender, System::Windows::Forms::KeyPressEventArgs^  e) {
				 if(KEY_DOWN(ENTER_KEY) && (commandBox->Text != ""))
				 {
					UserInterface UI;
					string commandString = UI.readUserInput(commandBox->Text);
					string results = UI.sendingInputToExecutor(commandString);
					 //string* display = Executor.executeCommand(commandBox->Text);
					 displayBox->Clear();
					 printMessage(results);
					 commandBox->Clear();
					 if(displayBox->Text == "Exiting...")
						 timerOut->Enabled = true;
				 }
			 }
	/*private: System::Void checkedTaskList_SelectedValueChanged(System::Object^  sender, System::EventArgs^  e) {
				 displayBox->Text = checkedTaskList->SelectedValue->ToString();
				 displayBox->Text += checkedTaskList->SelectedIndex;
			 }*/		//FOR FUTURE
private: System::Void timerOut_Tick(System::Object^  sender, System::EventArgs^  e) {
			 this->Close();
		 }
};
}


